<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<style>
  .btn{
    margin-top: 100px;
    width: 170px;
    height: 36px;
    background-color: red;
  }
  .opt{
    opacity: .5;
  }
</style>
<body>
  <div id="app">
    <input type="text" v-model="val" name="" id="">
    <span @click="del" v-show="flag">X</span>
    <div>
      <!-- disabled 禁用 -->
      <button  :disabled="dis" @click="submit" :class="{btn:true, opt: dis }">登录</button>

    </div>
  </div>


  <script>
    new Vue({
      el:'#app',
      data() {
        return {
          val:'',
          //控制X
          flag:false,
          //是否禁用
          dis:true
        }
      },
      watch:{
        val(newValue){
          if(newValue.length > 0){
            this.flag = true
            if(newValue.length  === 11){
              this.dis = false
            }else{
              this.dis = true 
            }
          }else{
            this.flag = false
          }
        }
      },
      methods: {
        //清空
        del(){
          this.val = ''
        },
        submit(){
          console.log("提交");
        }
      },
    })
  </script>
</body>
</html>